﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using UT3Bots.Communications;


namespace UT3Bots.UTItems
{
	public class UTItem
	{
		private UTIdentifier _id;
		private ItemType _itemType;
		private int _actualClass;


		#region Properties
		internal UTIdentifier Id
		{
			get
			{
				return this._id;
			}
		}

		/// <summary>
		/// The type of item
		/// </summary>
		public ItemType ItemType
		{
			get
			{
				return this._itemType;
			}
		}

		/// <summary>
		/// The actual item as an int, you might want to cast it to the correct (Weapon/Ammo/Health/Armor)Type Enum
		/// </summary>
		public int ActualClass
		{
			get
			{
				return this._actualClass;
			}
		}
		#endregion



		internal UTItem(Message invMessage) : this(invMessage.Arguments[0], invMessage.Arguments[1])
		{
		}

		internal UTItem(string Id, string Type)
		{

			this._id = new UTIdentifier(Id);

			WeaponType weaponType = Type.GetAsWeaponType();
			AmmoType ammoType = Type.GetAsAmmoType();
			HealthType healthType = Type.GetAsHealthType();
			ArmorType armorType = Type.GetAsArmorType();

			if (weaponType != WeaponType.None)
			{
				this._itemType = ItemType.Weapon;
				this._actualClass = (int)weaponType;
			}
			else if (ammoType != AmmoType.None)
			{
				this._itemType = ItemType.Ammo;
				this._actualClass = (int)ammoType;
			}
			else if (healthType != HealthType.None)
			{
				this._itemType = ItemType.Health;
				this._actualClass = (int)healthType;
			}
			else if (armorType != ArmorType.None)
			{
				this._itemType = ItemType.Armor;
				this._actualClass = (int)armorType;
			}


		}



		public bool IsItem(ItemType type)
		{
			if (this._itemType == type)
			{
				return true;
			}

			return false;
		}

		public bool IsItem(WeaponType type)
		{
			if (this._itemType == ItemType.Weapon && this._actualClass == (int)type)
			{
				return true;
			}

			return false;
		}

		public bool IsItem(HealthType type)
		{
			if (this._itemType == ItemType.Health && this._actualClass == (int)type)
			{
				return true;
			}

			return false;
		}

		public bool IsItem(ArmorType type)
		{
			if (this._itemType == ItemType.Armor && this._actualClass == (int)type)
			{
				return true;
			}

			return false;
		}

		public bool IsItem(AmmoType type)
		{
			if (this._itemType == ItemType.Ammo && this._actualClass == (int)type)
			{
				return true;
			}

			return false;
		}

        public override string ToString()
        {
            switch (this.ItemType)
            {
                case ItemType.Ammo:
                    switch ((AmmoType)this.ActualClass)
                    {
                        case AmmoType.Avril:
                            return "Avril ammo";

                        case AmmoType.BioRifle:
                            return "Bio rifle ammo";

                        case AmmoType.Enforcer:
                            return "Enforcer ammo";

                        case AmmoType.FlakCannon:
                            return "Flak cannon ammo";

                        case AmmoType.LinkGun:
                            return "Link gun ammo";

                        case AmmoType.RocketLauncher:
                            return "Rocket launcher ammo";

                        case AmmoType.ShockRifle:
                            return "Shock rifle ammo";

                        case AmmoType.SniperRifle:
                            return "Sniper rifle ammo";
                            
                        case AmmoType.Stinger:
                            return "Stinger ammo";

                        default:
                            return "Unknown";
                            
                    }
                    break;

                case ItemType.Armor:
                    switch ((ArmorType)this.ActualClass)
                    {
                        case ArmorType.Berserk:
                            return "Beserk powerup";

                        case ArmorType.ChestArmour:
                            return "Chest armor";

                        case ArmorType.Helmet:
                            return "Helmet";

                        case ArmorType.Invisibility:
                            return "invistibilty powerup";

                        case ArmorType.Invulnerability:
                            return "Invulnerability powerup";

                        case ArmorType.JumpBoots:
                            return "Jump boots";

                        case ArmorType.ShieldBelt:
                            return "Shield belt";

                        case ArmorType.ThighPads:
                            return "Thigh pad armor";

                        case ArmorType.MultiplyDamage:
                            return "Damaage multiplier powerup";

						default:
                            return "Unknown";
                            
                    }
                    break;

                case ItemType.Health:
                    switch ((HealthType)this.ActualClass)
                    {
                        case HealthType.HealthVial:
                            return "Health vial";

                        case HealthType.MediBox:
                            return "Medi box";

                        case HealthType.BigKegOHealth:
                            return "Big Keg o' Health";

						case HealthType.SuperHealth:
							return "Super Health";

						default:
                            return "Unknown";
                            
                    }
                    break;

                case ItemType.Weapon:
                    switch ((WeaponType)this.ActualClass)
                    {
                        case WeaponType.Avril:
                            return "Avril";

                        case WeaponType.BioRifle:
                            return "Bio rifle";

                        case WeaponType.Enforcer:
                            return "Enforcer";

                        case WeaponType.FlakCannon:
                            return "Flak cannon";

                        case WeaponType.ImpactHammer:
                            return "Impact hammer";

                        case WeaponType.InstaGibRifle:
                            return "Insta gib rifle";

                        case WeaponType.LinkGun:
                            return "Link gun";

                        case WeaponType.Redeemer:
                            return "Redeemer";

						case WeaponType.RocketLauncher:
							return "Rocket Launcher";

                        case WeaponType.ShockRifle:
                            return "Shock rifle";

                        case WeaponType.SniperRifle:
                            return "Sniper rifle";

                        case WeaponType.Stinger:
                            return "Stinger";

                        case WeaponType.Translocator:
                            return "Trans locator";

						default:
                            return "Unkown";
                    }
                    break;

				default:
                    return "Unknown";
            }

            return "Unknown";
        }
	}
}
